<template>
  <view :style="colorStyle">
    <view
      class="sellerModule"
      :style="{
        paddingTop: `${info.style.pTop * 2}rpx`,
        paddingLeft: `${info.style.pLeft * 2}rpx`,
        paddingRight: `${info.style.pRight * 2}rpx`,
        paddingBottom: `${info.style.pBottom * 2}rpx`,
        marginTop: `${info.style.mTop * 2}rpx`,
        marginLeft: `${info.style.mLeft * 2}rpx`,
        marginRight: `${info.style.mRight * 2}rpx`,
        marginBottom: `${info.style.mBottom * 2}rpx`,
        borderRadius: `${info.radius * 2}rpx`,
        background: `${info.bgColor}`,
      }"
    >
      <view
        class="info2"
        :style="{
          background: `${
            info.btnBgType == 1
              ? 'linear-gradient(180deg, var(--view-op-ten024) 0%, var(--view-op-ten0) 100%)'
              : 'linear-gradient(180deg, ' +
                info.titleBgColor1 +
                ' 0%, ' +
                info.titleBgColor2 +
                ' 100%)'
          }`,
        }"
      ></view>
      <view class="info1">
        <view class="titlebox flex aitems between">
          <view class="title" :style="{ color: `${info.titleColor}` }">
            {{ info.title }}
          </view>
          <view
            class="more flex aitems"
            :style="{ color: `${info.moreColor}` }"
            v-if="info.moreShow == 1"
            @click="gourl(`/pages/seller/seller`)"
          >
            <span>{{ info.more }}</span>
            <u-icon
              name="arrow-right"
              :color="`${info.moreColor}`"
              size="12"
            ></u-icon>
          </view>
        </view>

        <view class="sellerbox">
          <view class="sellerList" v-for="(q, indedx, key) in list" :key="key">
            <view
              v-if="q.backImg"
              :style="{
                backgroundImage: `linear-gradient(180deg,transparent,#fff),url(${q.backImg})`,
              }"
              class="filter"
            >
              <view class="gaosi-content"></view>
            </view>
            <view class="sellerinfo1 flex aitems">
              <image
                class="sellerLogo"
                :src="q.logo"
                mode="aspectFill"
                alt=""
              />
              <view class="sellerNameBox">
                <view class="sellerName">
                  {{ q.name }}
                </view>
                <view class="stars flex aitems">
                  <image
                    src="@/static/img7.png"
                    mode="widthFix"
                    v-for="(items, indexs) in q.score"
                    :key="'score' + indexs"
                  ></image>
                </view>
              </view>
            </view>
            <view
              class="sellerinfo2"
              :style="{
                color: `${info.btnColor}`,
                background: `${
                  info.btnBgType == 2 ? info.btnBgColor : 'var(--view-theme)'
                }`,
              }"
              @click="gourl(`/pages/seller/info?id=${q.id}`)"
            >
              {{ info.btn }}
            </view>
            <view class="sellerinfo3 flex aitems">
              <view
                v-for="(item, index, key) in q.goodsList"
                class="goodslist"
                :key="key"
                @click.stop="gourl(`/pages/goods/detail?id=${item.id}`)"
              >
                <view class="goodsinfo1">
                  <image
                    :src="item.img"
                    class="goodsimg"
                    alt=""
                    mode="aspectFill"
                  />
                  <view class="goodsprice">￥{{ item.goodsPrice }}</view>
                </view>
                <view class="goodsinfo2">{{ item.name }}</view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { sellerPage } from "@/servers/servers";
import colors from "@/mixins/color";
import { HTTP_STATUS } from "../../../servers/config";
import { go } from "../../../utils/wxAPI";
export default {
  mixins: [colors],
  props: {
    info: {
      default: {},
    },
  },
  data() {
    return {
      list: [],
    };
  },
  async mounted() {
    this.sellerPage();
  },
  methods: {
    async sellerPage() {
      let ids = [];
      this.info.value.map((item) => {
        ids.push(item.id);
      });
      let orderByAsc =
        this.info.sort == 2
          ? "salesVolume"
          : this.info.sort == 4
          ? "goodsPrice"
          : "";
      let orderByDesc =
        this.saleType == 3
          ? "salesVolume"
          : this.info.sort == 5
          ? "goodsPrice"
          : "";
      let { data } = await sellerPage({
        ids: ids.join(","),
        goodsNum: 3,
        orderByAsc,
        orderByDesc,
      });
      if (data.code == HTTP_STATUS.RUSELT_SUCCESS) {
        this.list = data.data.records;
      }
    },
    gourl(url) {
      go(url);
    },
  },
};
</script>

<style lang="scss" scoped>
.sellerModule {
  position: relative;
  overflow: hidden;

  //   box-shadow: 0px 2rpx 8rpx #c2c2c2;
  .info1 {
    position: relative;
    z-index: 1;

    .titlebox {
      .title {
        font-weight: bold;
        font-size: 32rpx;
      }

      .more {
        color: #1f1f1f;
        font-size: 24rpx;
      }
    }

    .sellerbox {
      .sellerList {
        position: relative;
        box-shadow: 0px 2rpx 8rpx #c2c2c2;
        background: #fff;
        margin: 32rpx 0 0;
        border-radius: 28rpx;
        padding: 24rpx;
        overflow: hidden;

        .filter {
          background-position: 50%;
          background-repeat: no-repeat;
          background-size: cover;
          filter: blur(0px);
          width: 100%;
          height: 320rpx;
          box-sizing: border-box;
          position: absolute;
          left: 0;
          top: 0;
          overflow: hidden;

          // background: #666;
          .gaosi-content {
            // background: #000;
            // position: absolute;
            // left: 0;
            // top: 0;
            // width: 100%;
            // height: 100%;
            // opacity: 0.6;
          }
        }

        .sellerinfo1 {
          position: relative;
          z-index: 1;

          .sellerLogo {
            width: 82rpx;
            height: 82rpx;
            border-radius: 14rpx;
            object-fit: cover;
          }

          .sellerNameBox {
            margin-left: 20rpx;
            .sellerName {
              color: #fff;
              font-size: 32rpx;
              font-weight: bold;
              // margin-left: 20rpx;
            }
            .stars {
              margin: 10rpx 0 0;

              image {
                width: 24rpx;
                height: 24rpx;
                margin: 0 8rpx 0 0;
              }
            }
          }
        }

        .sellerinfo2 {
          position: relative;
          z-index: 1;
          border-radius: 36rpx;
          background: linear-gradient(254deg, #6defd8 8.49%, #5ccedd 92.98%);
          padding: 12rpx 40rpx;
          font-size: 28rpx;
          color: #fff;
          position: absolute;
          right: 24rpx;
          top: 34rpx;
        }

        .sellerinfo3 {
          position: relative;
          z-index: 1;
          margin: 24rpx 0 0;

          .goodslist {
            width: 184rpx;
            margin: 0 20rpx 0 0;

            .goodsinfo1 {
              position: relative;
              border-radius: 24rpx;
              overflow: hidden;

              .goodsimg {
                width: 184rpx;
                height: 184rpx;
                border-radius: 24rpx;
                object-fit: cover;
              }

              .goodsprice {
                position: absolute;
                bottom: 0;
                right: 0;
                border-radius: 20rpx 0px 24rpx 20rpx;
                background: rgba(0, 0, 0, 0.6);
                font-size: 24rpx;
                color: #fff;
                font-weight: bold;
                padding: 4rpx 20rpx;
                z-index: 1;
              }
            }

            .goodsinfo2 {
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              color: #1f1f1f;
              font-size: 28rpx;
              padding: 8rpx;
            }
          }
        }
      }
    }
  }

  .info2 {
    height: 172rpx;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
  }
}
</style>
